// zhouyuyue_yajin/pages/feedback/feedback.js
let app = getApp();
let http = require('../../util/http.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    user_name:'',
    phone:'',
    cont:''
  },

  // 提交
  submit:function(){
    let that = this;
    if(that.data.cont==''){
      wx.showToast({
        title: '请输入内容',
        duration: 2500,
        icon: 'none',
        mask: true,
      });
      return
    };
    http.post('comp',{
      username:that.data.user_name,
      phone:that.data.phone,
      content:that.data.cont
    },function(res){
      console.log('反馈',res);
      if(res.data.errno==0){
        wx.showToast({
          title: '提交成功',
          duration: 2500,
          icon: 'none',
          mask: true,
        })
      }
    });
  },

  input:function(e){
    // console.log(e);
    this.setData({
      cont:e.detail.value
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    that.setData({
      user_name:wx.getStorageSync('userName'),
      phone:wx.getStorageSync('phone')
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})